<!-- 点位 》 门禁点位 -->

<template>
  <DeviceBody hasReset>
    <template #treeBottom>
      <BtnPrimary title="门禁点同步" @click="startSubmit" />
    </template>

    <MySearch />

    <MyTable />

    <MyModal />
  </DeviceBody>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import store from './store'
import mixDevice from '@admin/views/Secure/mixDevice'
import DeviceBody from '@admin/views/Secure/mixDevice/DeviceBody'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'PointAccess',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [mixDevice(store)],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 监听属性 (深度 deep 首次 immediate)
   */
  watch: {
    /**
     * 监听选中
     */
    'selectParam.treeId'() {
      const { selectParam, chosen, param, startList } = this
      const regionId = selectParam.areaId
      const deviceId = chosen.id || ''

      Object.assign(param, { regionId, deviceId, page: 1 })
      startList()
    },

    /**
     * 监听门禁点同步
     */
    readySubmit(ready) {
      if (ready) {
        this.setTree()
        this.initTree()
      }
    },

    /**
     * 监听弹窗可见
     */
    visible(visible) {
      visible && this.device_startList()
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: DeviceBody.methods,
}
</script>
